import request from '@/utils/request'
import qs from 'qs'

export function login(username, password, code, uuid) {
  return request({
    url: 'auth/login',
    method: 'post',
    data: {
      username,
      password,
      code,
      uuid
    }
  })
}

export function phoneLogin(username, code, uuid, pid) {
  return request({
    url: 'auth/phoneLogin',
    method: 'post',
    data: {
      username,
      pid,
      code,
      uuid
    }
  })
}

export function getInfo() {
  return request({
    url: 'auth/info',
    method: 'get'
  })
}

export function getCodeImg() {
  return request({
    url: 'auth/code',
    method: 'get'
  })
}

export function getPhoneCode(phone) {
  return request({
    url: 'auth/phoneCode',
    method: 'post',
    data: qs.stringify({
      phone
    })
  })
}

export function logout() {
  return request({
    url: 'auth/logout',
    method: 'delete'
  })
}
